﻿/// <reference name="MicrosoftAjax.js"/>
/// <reference path="Silverlight.js"/>
/// <reference path="aaagctrl.debug.js"/>
/// <reference path="SilverlightControlToolkit.debug.js"/>

ScrollingManager = function(host) {
    ScrollingManager.initializeBase(this, [ host ]);
    this._horizontalPageFlip = null;
    this._verticalPageFlip = null;
    this._pageFlipGroup = null;
    
    this._horizontalScrollBar = null;
    this._verticalScrollBar = null;
    this._scrollBarGroup = null;
}
ScrollingManager.prototype = 
{
    onSilverlightLoaded:function( slControl, args)
    {
         var p = this.get_plugin();
         var btnLeft = $create (SilverlightControlToolkit.Button,{plugin:p, elementName:"Left"},null,null);
         var btnRight = $create (SilverlightControlToolkit.Button,{plugin:p, elementName:"Right"},null,null);
         var btnTop = $create (SilverlightControlToolkit.Button,{plugin:p, elementName:"Top"},null,null);
         var btnBottom = $create (SilverlightControlToolkit.Button,{plugin:p, elementName:"Bottom"},null,null);
         
         this._horizontalPageFlip = new SilverlightControlToolkit.HorizontalPageFlipScroller();
         this._horizontalPageFlip.set_leftButton(btnLeft);
         this._horizontalPageFlip.set_rightButton(btnRight);
         
         this._verticalPageFlip = new SilverlightControlToolkit.VerticalPageFlipScroller();
         this._verticalPageFlip.set_bottomButton(btnBottom);
         this._verticalPageFlip.set_topButton(btnTop);
         
         this._pageFlipGroup = new SilverlightControlToolkit.ComposedScroller();
         this._pageFlipGroup.set_scrollers([this._horizontalPageFlip, this._verticalPageFlip]);
         
         this._horizontalScrollBar = new SilverlightControlToolkit.HorizontalScrollBar();
         this._horizontalScrollBar.set_minusBtn(btnLeft);
         this._horizontalScrollBar.set_plusBtn(btnRight);
         
         this._verticalScrollBar = new SilverlightControlToolkit.VerticalScrollBar();
         this._verticalScrollBar.set_minusBtn(btnTop);
         this._verticalScrollBar.set_plusBtn(btnBottom);
         
         this._scrollBarGroup = new SilverlightControlToolkit.ComposedScroller();
         this._scrollBarGroup.set_scrollers([this._horizontalScrollBar, this._verticalScrollBar]);
         
         var scrolledContent = $create(SilverlightControlToolkit.AgBehavior,
            {plugin:p, elementName:"Content"},null,null,null);
         var scrollContainer = $create(SilverlightControlToolkit.ScrollContainer,
            {plugin:p, elementName:"Container",content:scrolledContent,scroller:this._scrollBarGroup},null,null,null);
            
    },
    usePageFlip:function()
    {
        $find("Container").set_scroller(this._pageFlipGroup);
    },
    useScrollBars:function()
    {
        $find("Container").set_scroller(this._scrollBarGroup);
    }
}

ScrollingManager.registerClass("ScrollingManager", SilverlightControlToolkit.SLManager);